<?php 
include 'method/win.php';

if(!isset($_SESSION['adminuser'])){
    show_msg("请先登录!","A-login.php");
}
if(isset($_GET['action'])){
    logout();
}
if(isset($_POST['submit'])){
    $_SESSION['suser'] = $_POST['search-str'];
}
if(isset($_SESSION['suser'])){
    $defsql = "select * from weibo_user where user_name like '%".$_SESSION['suser']."%'";
    $defres = $conn->query($defsql);
}else {
    $defsql = "select * from weibo_user";
    $defres = $conn->query($defsql);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>删除微博账号</title>
    <link rel="stylesheet" href="css/A-public.css">
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.css">
    <script src="../lib/jquery/jquery.js" type="text/javascript"></script>
</head>
<body style="background-color:#a1a3a6;">
<h3>删除微博账号</h3>
<div class="user">

    <span class="span1">当前登录管理员为：<span class="username"><?php echo $_SESSION['adminuser']?></span></span>

    <a class="float-right leave" href="A-index.php?action=logout">退出</a>
    <a class="leave" href="A-index.php">返回</a>
</div>
<div class="well">
    <form class="search" method="post" action="">
        <input type="text" name="search-str" class="input-top" placeholder="请输入搜索内容">
        <button type="submit" name="submit" class="submit glyphicon glyphicon-search"/>
    </form>
</div>

<div class="table-div1 table-responsive choose-1" id="div">
    <table class="table1 table-bordered">
        <tr class="">
            <td>序号</td>
            <td>id</td>
            <td>账号</td>
            <td>操作</td>
        </tr>
        <?php 
        $no = 1;
        if($defres->num_rows){
            while ($rows = $defres->fetch_assoc()){
                echo "<tr class=''>";
                echo "<td>".$no."</td>";
                echo "<td>".$rows['user_id']."</td>";
                echo "<td>".$rows['user_name']."</td>";
                echo "<td width=15%>";
                echo "<button type='button' class='btn btn-default' onclick=delUser('".$rows['user_name']."')>删除</button>";
                echo "</td></tr>";
                $no = $no+1;
            }
        }else {
            echo "<tr class=''>暂无相关用户</tr>";
        }
        
        ?>
    </table>
</div>
</body>
<script type="text/javascript">
function delUser(str){
	var tipDelUser = confirm("你确定要删除此用户及其相关的信息？")
	if(tipDelUser){
		$.ajax({
            type:"post",
    		url:"method/deluser_action.php",
    		data:{str: str},
    		success:function(data){
    				alert(data)
    		}
        });
		location.reload();
	}
}
</script>
</html>